<template>
  <div class="goods_item_container">
    <div class="goods_item_img">
      <div class="left_choice_num" v-if="goodsDetail.colorNum">
        <div>{{ goodsDetail.colorNum }}</div>
        <div>色</div>
        <div>可</div>
        <div>选</div>
      </div>
      <div class="left_choice_num" v-else-if="goodsDetail.productPlace">
        <div v-for="item in goodsDetail.productPlace.split('')" :key="item">{{ item }}</div>
      </div>
      <div class="right_top_icon" v-if="goodsDetail.topLogo?.logoUrl">
        <img v-lazy="goodsDetail.topLogo?.logoUrl">
      </div>
      <img v-lazy="goodsDetail.listPicUrl">
    </div>
    <div class="goods_name">
      <span class="crowd_funding_icon" v-if="!!goodsDetail.preLogo?.length">
        <img v-for="item in goodsDetail.preLogo" :style="{ width: `${item.width / 2}px`, height: `${item.height / 2}px` }"
          style="margin-right: 5px;" :key="item.logoUrl" v-lazy="item.logoUrl">
      </span>
      <span class="goods_intro_name">{{ goodsDetail.name }}</span>
    </div>
    <div class="red_paper" v-if="goodsDetail.finalPriceInfoVO.banner?.content.includes('满')">
      <span><img src="https://yanxuan.nosdn.127.net/static-union/166909947513c0c8.png">可用红包</span>
    </div>
    <div class="payment_price">
      <span class="new_goods_price">{{ goodsDetail.finalPriceInfoVO.priceInfo.finalPrice?.prefix ? '到手' : '' }}￥
        <span class="price_size" style="line-height: 30px;">{{ goodsDetail.retailPrice }}</span>
        <span class="old_goods_price" v-if="goodsDetail.retailPrice != goodsDetail.sortOriginPrice">￥
          {{ goodsDetail.sortOriginPrice }}
        </span>
      </span>
    </div>
    <div class="full_reduction" v-if="!!goodsDetail.finalPriceInfoVO.banner?.content"
      :style="{ width: goodsDetail.finalPriceInfoVO.banner?.content && !goodsDetail.finalPriceInfoVO.banner?.title ? '68px' : '' }">
      <img class="icon" src="//yanxuan.nosdn.127.net/b268d0d2f46c41d3b3edf5fa33eea3de.png">
      <div class="full_reduction_str">
        <span class="full_reduction_str1" style="margin:2px 3px 0 0;padding-left:6px; ">
          {{ goodsDetail.finalPriceInfoVO.banner?.content }}
        </span>
        <span class="full_reduction_str2">{{ goodsDetail.finalPriceInfoVO.banner?.title }}</span>
      </div>
    </div>
  </div>
</template>

<script setup lang='ts'>
import { type ItemModel } from "@/api/home";
const props = defineProps<{
  goodsDetail: ItemModel
}>()

</script>

<style scoped lang="less">
// 单条商品
.goods_item_container {
  width: 177.5px;
  height: 300px;
  align-items: center;
  padding: 0 5px 26px;

  // 商品的图片
  .goods_item_img {
    position: relative;

    img {
      width: 172.5px;
      border-radius: 5%;
    }

    // 图片上的可选款数
    .left_choice_num {
      border: 0.5px solid #b4a078;
      top: 5px;
      left: 5px;
      position: absolute;
      width: 12px;
      font-size: 12px;
      background: #F4F4F4;
      text-align: center;
      padding: 6px 1px;


      &>div {
        line-height: 12px;
        color: #b4a078;
      }
    }

    .right_top_icon {
      position: absolute;
      top: 4px;
      right: 10px;

      img {
        width: auto;
        height: 27px;
      }
    }
  }

  // 商品名称
  .goods_name {
    height: 40px;
    line-height: 18px;
    overflow: hidden;

    &>span>img {
      vertical-align: bottom;
    }


    .crowd_funding_icon2 {
      margin-right: 5px;

      img {
        height: 15px;
        width: 15px;
      }
    }

    .goods_intro_name {
      font-size: 14px;
    }
  }

  // 红包
  .red_paper {
    margin: 4px 0;
    width: 67px;
    border: 1px solid #D9D9D9;
    border-radius: 10px;
    font-size: 12px;
    line-height: 18px;
    text-align: center;

    img {
      width: 10px;
      height: 10px;
    }
  }

  // 价格
  .payment_price {
    font-size: 12px;
    color: red;
    height: 30px;

    .price_size {
      font-size: 20px;
      font-weight: bold;
    }

    .old_goods_price {
      color: #999;
      text-decoration: line-through;
    }
  }

  // 满减
  .full_reduction {
    width: 172.5px;
    height: 23px;
    background-color: #FFE9EB;
    border-radius: 10px;
    float: left;
    position: relative;

    .icon {
      position: absolute;
      width: 10px;
      top: -2px;
      left: 18px;
      vertical-align: top;
    }

    .full_reduction_str {
      font-size: 12px;
      font-weight: bold;

      .full_reduction_str1 {
        display: inline-block;
        height: 19px;
        background: red;
        color: #fff;
        border-radius: 10px;
      }

      .full_reduction_str2 {
        color: #FA1E32;
      }
    }

  }
}
</style>